package com.WOWTradeNews.phone;



import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

import com.WOWTradeNewsTest.R;


/**
 * 
 * @author utopia
 *
 */
public class PreferentialActivity extends Activity {
	
	WebView pref;
	
//	ADEntivity entity;
	
	String url = "";
	String name = "";
	Button back;
	ProgressDialog pd;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.preferentia);
		pd = new ProgressDialog(this);
		pd.setCanceledOnTouchOutside(false);
		pd.setCancelable(true);
		pd.show();
		Intent intent = getIntent();
//		entity = (ADEntivity) intent.getSerializableExtra("entity");
		url = intent.getStringExtra("url");
		name = intent.getStringExtra("name");
		
		back = (Button) findViewById(R.id.back);
		back.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				finish();
			}
		});
		
		pref = (WebView) findViewById(R.id.preferential);
		pref.getSettings().setJavaScriptEnabled(true);
		pref.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				pref.loadUrl(url);
				return super.shouldOverrideUrlLoading(view, url);
			}

			@Override
			public void onPageFinished(WebView view, String url) {
				pd.dismiss();
				super.onPageFinished(view, url);
			}
			
		});
		
		pref.loadUrl(url);
		
	}
	
	
	@Override
    public void onBackPressed() {
        if (pref.canGoBack()) {
        	pref.goBack();
        } else {
            super.onBackPressed();
        }
    }
	
}
